home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue61 / Contract / SimpleAccountFrm.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2000-08-07  |  1.2 KB  |  58 lines

  1. unit SimpleAccountFrm;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.     AccountExample, StdCtrls;
  8.  
  9. type
  10.   TFrmAccountTest = class(TForm)
  11.     ListBox1: TListBox;
  12.     edtBalance: TEdit;
  13.     lblBalance: TLabel;
  14.     procedure FormCreate(Sender: TObject);
  15.   private
  16.       FAccount: TSimpleAccount;
  17.     procedure AddNewLine(const Text: string; Amount: Currency);
  18.   public
  19.     { Pblic declarations }
  20.   end;
  21.  
  22. var
  23.   FrmAccountTest: TFrmAccountTest;
  24.  
  25. implementation
  26.  
  27. {$R *.DFM}
  28.  
  29. procedure TFrmAccountTest.AddNewLine(const Text: string; Amount: Currency);
  30. var
  31.     Line: TAccountLine;
  32. begin
  33.   Line := FAccount.AddLine(Text,Amount);
  34.   ListBox1.Items.AddObject(Line.Text,Line);
  35. end;
  36.  
  37. procedure TFrmAccountTest.FormCreate(Sender: TObject);
  38. begin
  39.     FAccount := TSimpleAccount.Create;
  40.   {
  41.       Let's add some Account Lines
  42.   }
  43.   AddNewLine('Test Entry',150);
  44.   AddNewLine('Another Entry',-100);
  45.   AddNewLine('Entry # 3',300);
  46.   {
  47.       now lets calculate the balance
  48.   }
  49.     edtBalance.Text := FloatToStr(FAccount.Balance);
  50.   {
  51.       Ok, lets add another Account Line
  52.   }
  53.   AddNewLine('Big badaboom',50);
  54.     edtBalance.Text := FloatToStr(FAccount.Balance);  
  55. end;
  56.  
  57. end.
  58.